import { Config } from "../../Config"
import GameUtils from "../GameUtils"
import { BigEvolution, BigState } from "../core/Big"
import { Player } from "../core/Player"
import { BaseHandler } from "./BaseHandler"

export class 鼓舞Handler extends BaseHandler{

    鼓舞_嗜血狂战(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_鼓舞_嗜血狂战)
        player.arr_bigs.forEach(big => {
            if (big.evolution == BigEvolution.未转型) {
                big.addState(BigState.BLOODTHIRSTY)
            }
        })
        let startPoint = this.gameMgr.map_point.get(data.start)
        let big_start = startPoint.big
        big_start.actionOnce()
        this.gameMgr.sendBroadcast(GameUtils.getObj("play_sound",{"sound":"鼓舞_鼓舞","username":big_start.player.username}))
    }

    鼓舞_乘风破浪(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_鼓舞_乘风破浪)
        player.arr_bigs.forEach(big => {
            if (big.evolution == BigEvolution.未转型) {
                big.addState(BigState.WAVERIDER)
            }
        })
        let startPoint = this.gameMgr.map_point.get(data.start)
        let big_start = startPoint.big
        big_start.actionOnce()
        this.gameMgr.sendBroadcast(GameUtils.getObj("play_sound",{"sound":"鼓舞_鼓舞","username":big_start.player.username}))
    }

    鼓舞_生生不息(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_鼓舞_生生不息)
        player.arr_bigs.forEach(big => {
            if (big.evolution == BigEvolution.未转型) {
                big.addState(BigState.FERTILE)
            }
        })
        let startPoint = this.gameMgr.map_point.get(data.start)
        let big_start = startPoint.big
        big_start.actionOnce()
        this.gameMgr.sendBroadcast(GameUtils.getObj("play_sound",{"sound":"鼓舞_鼓舞","username":big_start.player.username}))
    }

    鼓舞_常胜将军(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_鼓舞_常胜将军)
        player.arr_bigs.forEach(big => {
            if (big.evolution == BigEvolution.未转型) {
                big.addState(BigState.HEROIC)
            }
        })
        let startPoint = this.gameMgr.map_point.get(data.start)
        let big_start = startPoint.big
        big_start.actionOnce()
        this.gameMgr.sendBroadcast(GameUtils.getObj("play_sound",{"sound":"鼓舞_鼓舞","username":big_start.player.username}))
    }

}